home *** CD-ROM | disk | FTP | other *** search
- Path: news.mistral.co.uk!usenet
- From: mikebarnard@mistral.co.uk (Mike Barnard)
- Newsgroups: comp.lang.c
- Subject: Initialising structure members - help please!
- Date: Mon, 19 Feb 1996 23:26:51 GMT
- Organization: Mistral Internet (Brighton)
- Message-ID: <4gb8hn$3m8@news.mistral.co.uk>
- NNTP-Posting-Host: l105.mistral.co.uk
- X-Newsreader: Forte Free Agent 1.0.82
-
- Hi all.
-
- I'm a learner. I am trying to create a function to display a list of
- menu items using a doubly linked list. My problem is in initialising
- the members of the individual menu items.
-
- Within a function called VPCMENU.C I have created a structure...
-
- // Define a structure to hold the menu item information.
-
- struct menuitem
- {
- int number; // Item 1, item 2 etc.
- char description[70]; // Room for a text description
- struct menuitem *next; // Pointer to next menu item
- struct menuitem *last; // Pointer to last menu item
- };
-
- Now I create 5 instances of variables of the type menuitem...
-
- // Define the instances of the structure.
-
- struct menuitem one,two,three,four,five;
-
- Now, the fun (not) bit. I tried to initialise the items with...
-
- one.number = 1;
- one.description = "1. Calculate a minefield";
- one.next = two;
- one.last = five;
-
- The first one passes OK, but the second one creates an error. As it
- stands it says "Lvalue required". Help says "The left side of an
- assignment operator must be an addressable expression." I don't know
- about the third and fourth ones. Yet.
-
- This is an almost exact copy of the structure examples in my book.
- (The beginners guide to C by Wrox). Page 387 for those who have it.
-
- So, can anyone help please? (I must get snippets!). This is for a PC
- in text mode using Borland C++ 3.0. The completed program is to do
- calculations for the e-mail game VGA Planets.
-
- Thanks.
-
-
- Mic.
- From windy Worthing; England.
- mikebarnard@mistral.co.uk
-
-